package thread;

// 使用 lambda 表达式, 创建匿名内部类
public class demo5 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println("lambda表达式创建的匿名内部类的子线程被执行了 " + i);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        thread.start();

        for (int i = 0; i < 10; i++) {
            System.out.println("主线程main方法被执行了 " + i);
            Thread.sleep(1000);
        }
    }
}
